package com.moorror.codegenvel.utils;

import org.apache.commons.collections4.CollectionUtils;

import java.util.List;
import java.util.Set;

/**
 * @Author jiyanghuang
 * @Date 2024/5/19 12:48
 */
public class SqliteUtils {

    public static String inSql(List<String> uriMd5s) {
        if (CollectionUtils.isEmpty(uriMd5s)) {
            return "";
        }
        StringBuilder sb = new StringBuilder();
        sb.append("(");
        for (String uriMd5 : uriMd5s) {
            sb.append("?");
            sb.append(",");
        }
        sb.deleteCharAt(sb.length() - 1);
        sb.append(")");
        return sb.toString();
    }

    public static String inSql(Set<String> values) {
        if (null == values || values.size() <= 0) {
            return "";
        }
        StringBuilder sb = new StringBuilder();
        sb.append("(");
        for (String uriMd5 : values) {
            sb.append("?");
            sb.append(",");
        }
        sb.deleteCharAt(sb.length() - 1);
        sb.append(")");
        return sb.toString();
    }
}
